package flc.ast.adapter;

import android.graphics.Color;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class AngleAdapter extends StkProviderMultiAdapter<String> {

    public AngleAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(40));
        addItemProvider(new AngleProvider());
    }

    private int selPosition;

    public void setSelPosition(int selPosition) {
        this.selPosition = selPosition;
    }

    private class AngleProvider extends BaseItemProvider<String> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_angle;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, String bean) {
            baseViewHolder.setText(R.id.tvAngleItemName, bean);
            if (baseViewHolder.getBindingAdapterPosition() == selPosition) {
                baseViewHolder.setTextColor(R.id.tvAngleItemName, Color.parseColor("#FFFFFF"));
                baseViewHolder.setBackgroundColor(R.id.rlAngleItem, Color.parseColor("#053CFF"));
            } else {
                baseViewHolder.setTextColor(R.id.tvAngleItemName, Color.parseColor("#8F8F8F"));
                baseViewHolder.setBackgroundColor(R.id.rlAngleItem, Color.parseColor("#F8FAFC"));
            }
        }
    }
}
